"""
@Author  : 康帅
@Time    : 2021/2/8 13:34
@Function: 使用一个名为bpmappers的三方库来简化将对象转成字典的操作，这个三方库本身也提供了对Django框架的支持
@install : pip install bpmappers
"""

"""url"""
# path('data_list_all/', views.data_list_all, name='data_list_all')

"""view"""
# from bpmappers.djangomodel import ModelMapper
#
#
# # model名需要修改
# class CountryMapper(ModelMapper):
#     # 修改name_cn返回字段的名称，例：原name_cn，现chinese_na
#     chinese_na = RawField('name_cn')
#
#     class Meta:
#         model = Country
#         # 移除不需要返回的字段
#         exclude = ('name_en', 'name_cn')
#
#
# def data_list_all(request):
#     data = Country.objects.all()
#     data_list = []
#     for subject in data:
#         # CountryMapper需要个上面的类对应
#         data_list.append(CountryMapper(subject).as_dict())
#     return JsonResponse({'coda': 200, 'data': data_list}, safe=False)
